#ifndef GPS_LEG_H
#define GPS_LEG_H

#include <QPointF>
#include <QColor>
#include <QRectF>
#include <QTextStream>
#include "modifiable.h"
#include "gps_point.h"

#define MAX_BASE_COLOR 8

class GPS_leg: public Modifiable
{
public:
    GPS_leg();
    ~GPS_leg();

    int id() const;
    QString title() const;
    void setTitle(const QString&);

    QColor color() const;
    void setColor(const QColor&);

    int nPoints() const;
    void addPoint(GPS_point*);
    const GPS_point* point(int) const;
    QPointF quickPoint(int) const;
    const GPS_point* lastPoint() const;
    int removeLastPoint();

    int lengthMt() const;

    QRectF boundingRect() const;

    QString serialize() const;
    static bool unserialize(QTextStream&, GPS_leg*);

private:
    GPS_leg(const GPS_leg&);
    int _id;
    QString _title;
    QColor _color;
    QList<GPS_point*> _points;
    QList<QPointF> _quickPoints;

    int length_mt;
    QRectF _boundingRect;
    void expandBoundingRect( double, double );
};

#endif // GPS_LEG_H
